import {
  createRouter,
  createWebHashHistory
} from 'vue-router';

const router = createRouter({
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('../views/Index.vue'),
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('../views/Register.vue')
    },
    {
      path: '/index',
      name: 'Index',
      component: () => import('../views/Index.vue'),
    },
    // 管理后台开始
    {
      path: '/admin',
      name: 'Admin',
      component: () => import('../admin/Admin.vue'),
      redirect: '/admin/login',
      children: [
        {
          path: '/admin/login',
          name: 'AdminLogin',
          component: () => import('../admin/Login.vue'),
        },
        {
          path: '/admin/index',
          name: 'AdminIndex',
          component: () => import('../admin/Index.vue'),
          redirect: '/admin/index/users',
          children: [
            {
              path: '/admin/index/users',
              name: 'AdminUsers',
              component: () => import('../admin/users/Users.vue'),
            }
          ]
        }
      ]
    },
    // 管理后台结束
    {
      path: '/404',
      name: '404',
      component: () => import('../views/404.vue'),
    }
  ],
  history: createWebHashHistory()
})

export default router;
